//
//  CourseShowView.m
//  BeanSproutEDU
//
//  Created by douya on 15/1/7.
//  Copyright (c) 2015年 douya. All rights reserved.
//

#import "CourseShowView.h"
#import "CourseDetailsViewController.h"
#import "UIImageView+WebCache.h"
#import "UIButton+WebCache.h"
#import "SDImageCache.h"
@implementation CourseShowView
-(id)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame])
    {
        self.showBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.showBtn.frame=CGRectMake(0, 0, frame.size.width, frame.size.height-15);
//        [self.showBtn addTarget:self action:@selector(showBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.showBtn];
        
        self.title=[[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.showBtn.frame)+2, frame.size.width, 25)];
        self.title.font=[UIFont systemFontOfSize:10];
        self.title.numberOfLines=2;
        [self addSubview:self.title];
        [self addImageView:@"noOpenPic.png" setTitle:@"豆芽"];
    }
    return self;
}

-(void)addImageView:(NSString *)image setTitle:(NSString *)string
{
    [self.showBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:image] forState:UIControlStateNormal];
    [self.title setText:string];
}
//点击了课程的头像 通知主界面controller进入对应课程的详细信息中去
-(void)showBtnClick
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushCourseDetailVC" object:nil];
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
